#ifndef KBORDERLESSBUTTON_H
#define KBORDERLESSBUTTON_H

#include "../screencapsdk_global.h"
#include <QIcon>
#include <QPushButton>
#include <QWidget>
#include <QEvent>

namespace kdk
{

/** @defgroup PushbuttonModule
  * @{
  */

class KBorderlessButtonPrivate;

/**
 * @brief 无边框按钮
 */
class SCREENCAPSDK_EXPORT KBorderlessButton:public QPushButton
{
    Q_OBJECT

public:
    KBorderlessButton(QWidget* parent = nullptr);
    KBorderlessButton(const QString &text, QWidget *parent = nullptr);
    KBorderlessButton(const QIcon &icon, const QString &text, QWidget *parent = nullptr);
    KBorderlessButton(const QIcon &icon, QWidget *parent = nullptr);
    ~KBorderlessButton();

    /**
     * @brief 设置按钮图标
     * @param icon
     */
    void setIcon(const QIcon &icon);

protected:
    bool eventFilter(QObject *watched, QEvent *event);
    void paintEvent(QPaintEvent *event);
    QSize sizeHint() const;

private:
    KBorderlessButtonPrivate* const d_ptr;
    Q_DECLARE_PRIVATE(KBorderlessButton)
    Q_PRIVATE_SLOT(d_ptr, void changeTheme())
};
}
/**
  * @example testPushbutton/widget.h
  * @example testPushbutton/widget.cpp
  * @}
  */
#endif

